package com.esri.core.internal.tasks.ags;

import com.esri.core.geometry.Envelope;
import com.esri.core.geometry.SpatialReference;
import com.esri.core.map.DynamicLayerInfo;
import com.esri.core.map.TimeExtent;
import com.esri.core.map.TimeOptions;
import java.io.IOException;
import java.io.StringWriter;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import org.codehaus.jackson.JsonGenerator;

/* loaded from: classes.dex */
public class m extends n {
    private static final long serialVersionUID = 1;
    Envelope a;
    int b;
    int c;
    String d;
    boolean e;
    SpatialReference f;
    SpatialReference g;
    boolean h;
    String i;
    Map<Integer, String> j;
    float k;
    private List<DynamicLayerInfo> o;
    private Map<Integer, TimeOptions> p;
    private TimeExtent q;
    private String r;

    @Override // com.esri.core.internal.tasks.f
    public boolean validate() {
        return false;
    }

    public m(Envelope envelope, SpatialReference spatialReference, int i, int i2) {
        this(envelope, spatialReference, i, i2, null);
    }

    public m(Envelope envelope, SpatialReference spatialReference, int i, int i2, List<DynamicLayerInfo> list) {
        this.b = -1;
        this.c = -1;
        this.d = "png";
        this.e = true;
        this.h = false;
        this.i = null;
        this.j = null;
        this.k = 0.0f;
        this.r = null;
        this.a = envelope;
        this.b = i;
        this.c = i2;
        this.g = spatialReference;
        this.o = list;
    }

    public Envelope a() {
        return this.a;
    }

    public void a(Envelope envelope) {
        this.a = envelope;
    }

    public int b() {
        return this.b;
    }

    public void a(int i) {
        this.b = i;
    }

    public int c() {
        return this.c;
    }

    public void b(int i) {
        this.c = i;
    }

    public String d() {
        return this.d;
    }

    public void a(String str) {
        this.d = str;
    }

    public boolean e() {
        return this.e;
    }

    public void a(boolean z) {
        this.e = z;
    }

    public SpatialReference f() {
        return this.f;
    }

    public void a(SpatialReference spatialReference) {
        this.f = spatialReference;
    }

    public boolean g() {
        return this.h;
    }

    public void b(boolean z) {
        this.h = z;
    }

    public String h() {
        return this.i;
    }

    public void b(String str) {
        if (str != null && str.trim().length() < 1) {
            str = "-1";
        }
        this.i = str;
    }

    public void a(float f) {
        this.k = f;
    }

    public List<DynamicLayerInfo> i() {
        return this.o;
    }

    public void a(List<DynamicLayerInfo> list) {
        this.o = list;
    }

    public Map<Integer, TimeOptions> j() {
        return this.p;
    }

    public void a(Map<Integer, TimeOptions> map) {
        this.p = map;
    }

    public TimeExtent k() {
        return this.q;
    }

    public void a(TimeExtent timeExtent) {
        this.q = timeExtent;
    }

    @Override // com.esri.core.internal.tasks.f
    /* renamed from: l */
    public HashMap<String, String> generateRequestParams() {
        LinkedHashMap linkedHashMap = new LinkedHashMap();
        linkedHashMap.put("f", this.h ? "json" : "image");
        if (this.a != null) {
            linkedHashMap.put("bbox", this.a.getXMin() + "," + this.a.getYMin() + "," + this.a.getXMax() + "," + this.a.getYMax());
            if (o() && q()) {
                linkedHashMap.put("bboxSR", c(this.g));
            } else {
                SpatialReference spatialReference = this.g;
                if (spatialReference != null) {
                    linkedHashMap.put("bboxSR", Integer.toString(spatialReference.getID()));
                }
            }
        }
        if (this.b > 0 && this.c > 0) {
            linkedHashMap.put("size", this.b + "," + this.c);
        }
        String str = this.d;
        if (str != null) {
            linkedHashMap.put("format", str);
        }
        linkedHashMap.put("transparent", this.e ? "true" : "false");
        float f = this.k;
        if (f > 0.0f) {
            linkedHashMap.put("dpi", Integer.toString((int) f));
        }
        if (this.f != null) {
            if (o() && q()) {
                linkedHashMap.put("imageSR", c(this.f));
            } else {
                linkedHashMap.put("imageSR", Integer.toString(this.f.getID()));
            }
        }
        Map<Integer, String> map = this.j;
        if (map != null && !map.isEmpty()) {
            StringBuilder sb = new StringBuilder();
            boolean z = true;
            for (Map.Entry<Integer, String> entry : this.j.entrySet()) {
                if (z) {
                    z = false;
                } else {
                    sb.append(';');
                }
                sb.append(entry.getKey());
                sb.append(':');
                sb.append(entry.getValue());
            }
            linkedHashMap.put("layerDefs", sb.toString());
        }
        List<DynamicLayerInfo> list = this.o;
        if (list != null && !list.isEmpty()) {
            StringWriter stringWriter = new StringWriter();
            try {
                JsonGenerator a = com.esri.core.internal.util.d.a(stringWriter);
                a.writeStartArray();
                for (DynamicLayerInfo dynamicLayerInfo : this.o) {
                    a.writeRawValue(dynamicLayerInfo.toJson());
                }
                a.writeEndArray();
                a.close();
            } catch (IOException e) {
                e.printStackTrace();
            } catch (Exception e2) {
                e2.printStackTrace();
            }
            linkedHashMap.put("dynamicLayers", stringWriter.toString());
        }
        Map<Integer, TimeOptions> map2 = this.p;
        if (map2 != null && !map2.isEmpty()) {
            StringWriter stringWriter2 = new StringWriter();
            try {
                JsonGenerator a2 = com.esri.core.internal.util.d.a(stringWriter2);
                a2.writeStartObject();
                for (Integer num : this.p.keySet()) {
                    a2.writeFieldName(num.toString());
                    a2.writeRawValue(this.p.get(num).toJson());
                }
                a2.writeEndObject();
                a2.close();
            } catch (IOException e3) {
                e3.printStackTrace();
            } catch (Exception e4) {
                e4.printStackTrace();
            }
            linkedHashMap.put("layerTimeOptions", stringWriter2.toString());
        }
        TimeExtent timeExtent = this.q;
        if (timeExtent != null) {
            linkedHashMap.put("time", timeExtent.toString());
        }
        String str2 = this.i;
        if (str2 != null && str2.trim().length() > 0) {
            linkedHashMap.put("layers", "hide:" + this.i);
        }
        String str3 = this.r;
        if (str3 != null && str3.length() > 0) {
            linkedHashMap.put("gdbVersion", this.r);
        }
        return linkedHashMap;
    }

    public Map<Integer, String> m() {
        return this.j;
    }

    public void b(Map<Integer, String> map) {
        this.j = map;
    }

    public String n() {
        return this.r;
    }

    public void c(String str) {
        this.r = str;
    }
}
